.PHONY: 3rd skynet clean

all : 3rd

help:
	@echo "支持下面命令:"
	@echo "make install       	# 编译项目"
	@echo "make 3rd       		# 编译 3rd "
	@echo "make skynet       	# 编译 skynet"
	@echo "make clean       	# 清理"
	@echo "make cleanall    	# 清理所有"

LUA_CLIB_PATH ?= luaclib
LUA_INCLUDE_DIR ?= skynet/3rd/lua
CFLAGS = -g -O0 -Wall -I$(LUA_INCLUDE_DIR)
SHARED := -fPIC --shared

3rd: skynet
	git submodule update --init
	cd 3rd/lua-cjson && $(MAKE) install LUA_INCLUDE_DIR=../../skynet/3rd/lua DESTDIR=../.. LUA_CMODULE_DIR=./luaclib CC='$(CC) -std=gnu99'

# TLS_MODULE=ltls
skynet:
	git submodule update --init
	cd skynet && $(MAKE) linux 

clean:
	rm -f luaclib/*.so

cleanall: clean
	cd 3rd/lua-cjson && make clean
	cd skynet && make cleanall


############################第三方库编译为so临时用###########################
# $(LUA_CLIB_PATH) :
# 	mkdir $(LUA_CLIB_PATH)

# $(LUA_CLIB_PATH)/cjson.so : 3rd/lua-cjson/lua_cjson.c 3rd/lua-cjson/strbuf.c 3rd/lua-cjson/fpconv.c | $(LUA_CLIB_PATH)
# 	$(CC) $(CFLAGS) $(SHARED) -I3rd/lua-cjson $^ -o $@

# LUA_CLIB = cjson

# build: \
#   	$(LUA_CLIB_PATH) \
#   	$(foreach v, $(LUA_CLIB), $(LUA_CLIB_PATH)/$(v).so)